/*
 * HSJoystick.h
 *
 *  Created on: Dec 30, 2012
 *      Author: grygula
 */

#ifndef HSJOYSTICK_H_
#define HSJOYSTICK_H_

#pragma once
#include "cocos2d.h"

using namespace cocos2d;

class HSJoystick : public CCLayer
{

public:

    virtual bool init();
    CCPoint getVelocity(){return velocity;}
    LAYER_NODE_FUNC(HSJoystick);

private:

    CCPoint kCenter;
    CCSprite *thumb;
    bool isPressed;

    CCPoint velocity;

    void updateVelocity(CCPoint point);
    void resetJoystick();
    bool handleLastTouch();
    void ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent);
    void ccTouchesMoved(CCSet *pTouches, CCEvent *pEvent);
    void ccTouchCancelled(CCTouch *pTouch, CCEvent *pEvent);
    void ccTouchesEnded(CCSet *pTouches, CCEvent *pEvent);

};

#endif /* HSJOYSTICK_H_ */
